<template>
  <div class="home">
    <el-carousel height="500px" indicator-position="outside">
      <el-carousel-item v-for="(item, index) in posterList" :key="index">
        <img class="CarImg" :src="item.url" alt="" />
      </el-carousel-item>
    </el-carousel>
    <div class="as">
      <div class="top">
        <span>热门榜单Top10</span>
        <div class="top1">
          <router-link :to="'/film/detail?fid=' + top1.id">
            <img width="120" height="160" :src="top1.cover" />
            <ul class="top1_text">
              <li>{{ top1.name }}</li>
              <li>上映时间：{{ top1.releaseTime }}</li>
              <li class="hot_text">热度值：{{ top1.hot }}</li>
            </ul>
          </router-link>
        </div>

        <div class="top2">
          <router-link
            :to="'/film/detail?fid=' + top2.id"
            style="text-decoration: none"
          >
            <img width="160" height="200" :src="top2.cover" />
            <p>{{ top2.name }}</p>
            <p class="top2_hot">热度值：{{ top2.hot }}</p>
          </router-link>
        </div>

        <div class="top3">
          <router-link
            :to="'/film/detail?fid=' + top3.id"
            style="text-decoration: none"
          >
            <img width="160" height="200" :src="top3.cover" />
            <p>{{ top3.name }}</p>
            <p class="top3_hot">热度值：{{ top3.hot }}</p>
          </router-link>
        </div>

        <div class="more_top">
          <ul class="more_top_style">
            <li v-for="(item, index) in moreList" :key="index">
              <span class="more_number">{{ index + 4 }}</span>
              <span class="more_name">{{ item.name }}</span>
              <span class="more_hot">热度值：{{ item.hot }}</span>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="main">
      <h2>热门电影</h2>
      <ul class="film_list">
        <li v-for="(item, index) in filmList" :key="index" class="film_style">
          <img width="150px" height="200px" :src="item.cover" />
          <h2 class="bg"></h2>
          <h3 class="film_name">{{ item.name }}</h3>
          <p class="film_list_people">{{ item.people }}人想看</p>
          <p class="film_list_releaseTime">{{ item.releaseTime }}上映</p>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { ListAllPoster, ListAllFilm, ListHots } from "@/api/film";
export default {
  data() {
    return {
      //定义轮播图数组
      posterList: [
        // {
        //   url_show: require("../assets/filmImg/kz.jpg"),
        // },
        // {
        //   url_show: require("../assets/filmImg/hszz.jpg"),
        // },
        // {
        //   url_show: require("../assets/filmImg/cjh.jpg"),
        // },
      ],
      topList: [], //用来接收后台数据

      top1: {
        // cover_show: require("../assets/filmImg/lihuanying.jpg"),
        // name: "李焕英",
        // releaseTime: "2020-12-22",
        // hot: "8",
      },
      top2: {
        // cover_show: require("../assets/filmImg/renchaoxiongyong.jpg"),
        // name: "人潮汹涌",
        // hot: "2",
      },
      top3: {
        // cover_show: require("../assets/filmImg/renchaoxiongyong.jpg"),
        // name: "人潮汹涌",
        // hot: "2",
      },
      moreList: [
        {
          name: "xxxx",
          hot: "99",
        },
        {
          name: "xxxx",
          hot: "99",
        },
        {
          name: "xxxx",
          hot: "99",
        },
        {
          name: "xxxx",
          hot: "99",
        },
        {
          name: "xxxx",
          hot: "99",
        },
        {
          name: "xxxx",
          hot: "99",
        },
        {
          name: "xxxx",
          hot: "99",
        },
      ],
      filmList: [
        // {
        //   name: "电影1",
        //   cover_show: require("../assets/filmImg/shouyiren.jpg"),
        //   releaseTime: "2021-12-22",
        //   people: "12",
        // },
        // {
        //   name: "电影2",
        //   cover_show: require("../assets/filmImg/fengshenbang.jpg"),
        //   releaseTime: "2021-12-23",
        //   people: "34",
        // },
        // {
        //   name: "电影3",
        //   cover_show: require("../assets/filmImg/cishaxiaoshuojia.jpg"),
        //   releaseTime: "2021-12-24",
        //   people: "56",
        // },
        // {
        //   name: "电影4",
        //   cover_show: require("../assets/filmImg/xxyw.jpg"),
        //   releaseTime: "2021-12-25",
        //   people: "71",
        // },
        // {
        //   name: "电影1",
        //   cover_show: require("../assets/filmImg/shouyiren.jpg"),
        //   releaseTime: "2021-12-22",
        //   people: "12",
        // },
        // {
        //   name: "电影2",
        //   cover_show: require("../assets/filmImg/fengshenbang.jpg"),
        //   releaseTime: "2021-12-23",
        //   people: "34",
        // },
        // {
        //   name: "电影3",
        //   cover_show: require("../assets/filmImg/cishaxiaoshuojia.jpg"),
        //   releaseTime: "2021-12-24",
        //   people: "56",
        // },
        // {
        //   name: "电影4",
        //   cover_show: require("../assets/filmImg/xxyw.jpg"),
        //   releaseTime: "2021-12-25",
        //   people: "71",
        // },
        // {
        //   name: "电影5",
        //   cover_show: require("../assets/filmImg/wdjj.jpg"),
        //   releaseTime: "2021-12-26",
        //   people: "85",
        // },
        // {
        //   name: "电影5",
        //   cover_show: require("../assets/filmImg/wdjj.jpg"),
        //   releaseTime: "2021-12-26",
        //   people: "85",
        // },
        // {
        //   name: "电影5",
        //   cover_show: require("../assets/filmImg/wdjj.jpg"),
        //   releaseTime: "2021-12-26",
        //   people: "85",
        // },
        // {
        //   name: "电影5",
        //   cover_show: require("../assets/filmImg/wdjj.jpg"),
        //   releaseTime: "2021-12-26",
        //   people: "85",
        // },
      ],
      status: 1,
    };
  },
  mounted() {
    this.posterQuery();
    this.nowplaying();
    this.topListQuery();
  },
  methods: {
    //轮播图
    posterQuery() {
      ListAllPoster().then((res) => {
        if (res.code == 200) {
          this.posterList = res.data;
        } else {
          this.$message({
            message: res.msg,
            type: "warning",
          });
        }
      });
    },
    //正在热播
    nowplaying() {
      ListAllFilm().then((res) => {
        if (res.code == 200) {
          this.filmList = res.data;
        }
      });
    },
    topListQuery() {
      ListHots().then((res) => {
        if (res.code == 200) {
          this.topList = res.data;
          this.top1 = this.topList[0];
          this.top2 = this.topList[1];
          this.top3 = this.topList[2];
          this.topList.splice(0, 3);
        }
      });
    },
  },
};
</script>
<style lang="scss">
.home {
  .CarImg {
    width: 100%;
  }
  .as {
    width: 32%;
    height: 1000px; //删除
    // background: rgb(13, 248, 236);
    float: right;
    .top {
      width: 430px;
      height: 250px;
      // background: blueviolet;
      span {
        font-size: 26px;
        color: orange;
      }
      .top1 {
        margin: 20px 0;
        border: 1px solid #eee;
        height: 160px;
        img {
          float: left;
        }
        .top1_text {
          list-style: none;
          float: left;
          height: 30px;
          line-height: 30px;
          font-size: 16px;
          padding-left: 20px;
          margin-top: 20px;
          color: #91949c;

          // background: antiquewhite;
          .hot_text {
            font-size: 13px;
            color: orange;
          }
        }
      }
      .top2 {
        width: 160px;
        color: #91949c;
        font-size: 14px;
        border: 1px solid #eee;
        // background: darkcyan;
        margin-right: 35px;
        margin-top: 10px;
        float: left;
        p {
          height: 13px;
          line-height: 12px;
          margin: 10px;
        }
        .top2_hot {
          font-size: 11px;
          color: orange;
        }
      }
      .top3 {
        float: left;
        width: 160px;
        color: #91949c;
        font-size: 14px;
        margin-top: 10px;
        border: 1px solid #eee;
        // background: darkcyan;
        p {
          height: 13px;
          line-height: 12px;
          margin: 10px;
        }
        .top3_hot {
          font-size: 11px;
          color: orange;
        }
      }
      .more_top {
        clear: both;
        padding-top: 25px;
        width: 350px;
        // float: left;
        .more_top_style {
          list-style: none;
          span {
            height: 50px;
            line-height: 50px;
            font-size: 16px;
            display: inline-block;
            // list-style: none;
            font-size: 16px;
          }
          .more_number {
            width: 25px;
            height: 30px;
            // display: block;
            color: #91949c;
            // list-style: none;
            float: left;
          }
          .more_name {
            color: #000;
            margin-left: 10px;
            // list-style: none;
            font-size: 18px;
          }
          .more_hot {
            color: orange;
            // list-style: none;
            float: right;
          }
        }
      }
    }
  }
  .main {
    width: 65%;
    height: 1000px;
    // background: aqua;
    .film_list {
      // width: 1000px;
      list-style: none;
      .film_style {
        width: 150px;
        // background: pink;
        float: left;
        margin-left: 55px;
        margin-top: 10px;
        position: relative;
        top: 0;
        left: 0;
        .bg {
          position: absolute;
          width: 150px;
          height: 35px;
          line-height: 35px;
          background-color: #000;
          opacity: 0;
          bottom: 83px;
        }
        .film_list_people {
          display: block;
          width: 150px;
          height: 30px;
          line-height: 30px;
          background: rgba(233, 233, 235, 0.411);
          // text-align: center;
          color: orange;
        }
        .film_list_releaseTime {
          display: block;
          width: 150px;
          height: 50px;
          line-height: 50px;
          color: #91949c8c;
          // background: red;
          font-size: 14px;
          // font-weight: bold;
          text-align: center;
        }
      }

      .film_name {
        position: absolute;
        bottom: 83px;
        height: 35px;
        line-height: 35px;
        // background: red;
        width: 150px;
        text-align: center;
        color: white;
        font-size: 14px;
        opacity: 0;
        z-index: 99;
      }
    }
    .film_list li:hover .bg {
      opacity: 0.6;
    }
    .film_list li:hover .film_name {
      opacity: 1;
    }
  }
}
</style>